const http = require('../../../utils/http.js'); 
Page({

  /**
   * 页面的初始数据
   */
  data: {
    ownerInfo: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    http.postRequest('/mini/v1/car_owner/owner_info',{owner_id: options.id},res=> {
      if(res.data.enter_time)res.data.time = this.js_date_time(res.data.enter_time);
      this.setData({
        ownerInfo: res.data
      })
    })
  },
  gopage(e) {
    wx.navigateTo({
      url: "/pages/classify/child/Tracker?id=" + e.currentTarget.dataset.ownerid
    })
  },
  js_date_time(unixtime) {
    var dateTime = new Date(parseInt(unixtime) * 1000)
    var year = dateTime.getFullYear();
    var month = dateTime.getMonth() + 1;
    var day = dateTime.getDate();
    var hour = dateTime.getHours();
    var minute = dateTime.getMinutes();
    var second = dateTime.getSeconds();
    var now = new Date();
    var now_new = Date.parse(now.toDateString());
    var milliseconds = now_new - dateTime;
    var timeSpanStr = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
    return timeSpanStr;
  },
  jumpWash() {
    wx.navigateTo({
      url: '/pages/openCard/openCard/openCard?mobile=' + this.data.ownerInfo.mobile
    })
  }
})